/*
	Copyright (c) 2009, SpLib.net
  	All rights reserved.
  	
  	Author:6spring
  	About:对象标识ID
*/

package SpLib.ObjSys
{
	public class GOID
	{
		public var m_nWndIDH:uint;			//进程ID高位
		public var m_nWndIDL:uint;			//进程ID低位
		public var m_nObjIDH:uint;			//对象ID高位
		public var m_nObjIDL:uint;			//对象ID低位
		
		public function GOID(source:Array=null)
		{
			if(source!=null)
			{
				m_nWndIDH = source[0];
				m_nWndIDL = source[1];
				m_nObjIDH = source[2];
				m_nObjIDL = source[3];
			}
			else
			{
				m_nWndIDH = 0;
				m_nWndIDL = 0;
				m_nObjIDH = 0;
				m_nObjIDL = 0;
			}	
		}
		
		public function Clear():void
		{
			m_nWndIDH = 0;
			m_nWndIDL = 0;
			m_nObjIDH = 0;
			m_nObjIDL = 0;
		}
		
		public function SetAsArray(source:Array):void
		{
			m_nWndIDH = source[0];
			m_nWndIDL = source[1];
			m_nObjIDH = source[2];
			m_nObjIDL = source[3];
		}
		
		public function GetAsArray():Array
		{
			return [m_nWndIDH,m_nWndIDL,m_nObjIDH,m_nObjIDL];
		}

		public function IsEmpty():Boolean
		{
			return (m_nWndIDH==0 && m_nWndIDL==0 && m_nObjIDH==0 && m_nObjIDL==0);
		}
		
	
		public function toString():String
		{
			return "GOID[" + m_nWndIDH + "," + m_nWndIDL + "," + m_nObjIDH + "," + m_nObjIDL + "]";
		}
		
		public function equal(rhs:GOID):Boolean
		{
			return m_nWndIDH==rhs.m_nWndIDH
					&& m_nWndIDL==rhs.m_nWndIDL
					&& m_nObjIDH==rhs.m_nObjIDH
					&& m_nObjIDL==rhs.m_nObjIDL;
		}
		
		static public function compare(rh1:GOID,rh2:GOID):int
		{
			if(rh1.m_nWndIDH>rh2.m_nWndIDH) return 1;
			if(rh1.m_nWndIDH<rh2.m_nWndIDH) return -1;
			
			if(rh1.m_nWndIDL>rh2.m_nWndIDL) return 1;
			if(rh1.m_nWndIDL<rh2.m_nWndIDL) return -1;
			
			if(rh1.m_nObjIDH>rh2.m_nObjIDH) return 1;
			if(rh1.m_nObjIDH<rh2.m_nObjIDH) return -1;
			
			if(rh1.m_nObjIDL>rh2.m_nObjIDL) return 1;
			if(rh1.m_nObjIDL<rh2.m_nObjIDL) return -1;
			
			return 0;
		}
	}
}